package com.easyfun.healthmagicbox.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class CustomViewPager extends ViewPager {

	private boolean enabled;

	public CustomViewPager(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.enabled = true;
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if (this.enabled) {
			boolean result = false;
			try
			{
				result = super.onTouchEvent(event);
			}catch (Exception e)
			{
				e.printStackTrace();
			}
			return result;
		}

		return false;
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent event) {
		if (this.enabled) {
			try{
				boolean sup = super.onInterceptTouchEvent(event);
				return sup;
			}catch(Exception e){
				e.printStackTrace();
				return false;
			}
		}

		return false;
	}

	public void setPagingEnabled(boolean enabled) {
		this.enabled = enabled;
	}
}
